Stored Procedures [dbo].[amsp_ICRenum]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Permissions
TypeActionOwning Principal
GrantExecuteIMIS
SQL Script
CREATE   procedure amsp_ICRenum AS
BEGIN

/*
** 03/21/2003  N.Malhotra    Created from amsp_NavMenuRenum
*/


  DECLARE
    @SortIncrement    integer,
    @NumICs        integer

  CREATE TABLE #temp (
    ID Numeric Identity not null,
    InterestCategoryID numeric,
    SortOrder numeric)

  BEGIN TRANSACTION
   
  INSERT INTO #temp (InterestCategoryID, SortOrder)
  SELECT InterestCategoryID, SortOrder
    FROM Interest_Category
   ORDER BY AncestorOrder, SortOrder

  SELECT @NumICs = count(*)
    FROM Interest_Category

  SET @SortIncrement = CEILING(999990000.0 / @NumICs) - 1

  UPDATE #Temp
     SET SortOrder = ID * @SortIncrement

  CREATE UNIQUE INDEX IDX_TEMP_1 ON #Temp(InterestCategoryID)

  UPDATE Interest_Category
     SET SortOrder = t.SortOrder
    FROM #temp t
   WHERE Interest_Category.InterestCategoryID = t.InterestCategoryID

  COMMIT TRANSACTION


END

GO
GRANT EXECUTE ON  [dbo].[amsp_ICRenum] TO [IMIS]
GO
Uses